package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrdersMapper {

    void insert(Orders orders);

    /**
     * 根据订单号和用户id查询订单
     * @param orderNumber
     * @param userId
     */
    @Select("select * from orders where number = #{orderNumber} and user_id= #{userId}")
    Orders getByNumberAndUserId(String orderNumber, Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);


    Page<Orders> pageQueryById(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from sky_take_out.orders where id = #{id}")
    Orders queryById(Long id);
    @Select("select * from sky_take_out.orders where status = #{status} and order_time < #{now}")
    List<Orders> statusAndCreatime(Integer status, LocalDateTime now);



    /*
    */
/**
     * 接单
     * 需要优化  后期更改
     * @param id
     * @return
     *//*

    //TODO 需要优化  后期更改  （已被优化 可以瞅瞅经验+3）
    @Select("select * from sky_take_out.orders where id = #{id}")
    Orders queryById1(Long id);
*/

}